package com.bw.liuyushan.zhuangao4_weektest2.MVP.Model;

import com.bw.liuyushan.mvp_lib.Model.BaseModel;
import com.bw.liuyushan.zhuangao4_weektest2.Entity.GiftBean;
import com.bw.liuyushan.zhuangao4_weektest2.Entity.UserBean;
import com.bw.liuyushan.zhuangao4_weektest2.Entity.VideoBean;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Contrack.IContrackTest;
import com.bw.liuyushan.zhuangao4_weektest2.RequestApi.APIGift;
import com.bw.liuyushan.zhuangao4_weektest2.RequestApi.APIMain;
import com.bw.liuyushan.zhuangao4_weektest2.RequestApi.APIUser;
import com.bw.liuyushan.zhuangao4_weektest2.Utils.GiftRxJavaManager;
import com.bw.liuyushan.zhuangao4_weektest2.Utils.UserRxJavaManager;
import com.bw.liuyushan.zhuangao4_weektest2.Utils.VideoRxJavaManager;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * ZhuanGao4_WeekTest2
 * file name is : BaseModelTest
 * created by Ender on 2021/8/23 8:27.
 * author : 刘雨杉
 * Describe(作用):
 */
public class BaseModelTest extends BaseModel implements IContrackTest.C_ModelTest {
    @Override
    public void askVideo(String url, Observer<VideoBean> observer) {
        VideoRxJavaManager.getInstance().getRetrofit().create(APIMain.class)
                .VideoTest(url)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    @Override
    public void asklogin(String username, String password, Observer<UserBean> observer) {
        UserRxJavaManager.getInstance().getRetrofit().create(APIUser.class)
                .loginTest(username, password)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    @Override
    public void askreg(String username, String password, String repassword, Observer<UserBean> observer) {
        UserRxJavaManager.getInstance().getRetrofit().create(APIUser.class)
                .regTest(username, password, repassword)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    @Override
    public void askGift(Observer<GiftBean> observer) {
        GiftRxJavaManager.getInstance().getRetrofit().create(APIGift.class)
                .GiftTest()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);

    }
}
